package com.cskaoyan.wx.service;

import com.cskaoyan.bean.Category;
import com.cskaoyan.mapper.CategoryMapper;
import com.cskaoyan.wx.bean.vo.WxCataLogVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ description:
 * @ author:台
 **/

@Service
public class WxCataLogServiceImpl implements WxCataLogService {

    @Autowired
    CategoryMapper categoryMapper;

    @Override
    public WxCataLogVo wxCatalogIndex() {
        List<Category> categoryList = categoryMapper.selectWxAllByPid(0);
        Category currentCategory = categoryMapper.selectByPrimaryKey(1005000);
        List<Category> currentSubCategory = categoryMapper.selectWxAllByPid(currentCategory.getId());
        WxCataLogVo wxCataLogVo = new WxCataLogVo();
        wxCataLogVo.setCategoryList(categoryList);
        wxCataLogVo.setCurrentCategory(currentCategory);
        wxCataLogVo.setCurrentSubCategory(currentSubCategory);
        return wxCataLogVo;
    }

    @Override
    public WxCataLogVo wxCatalogCurrent(Integer id) {
        Category currentCategory = categoryMapper.selectByPrimaryKey(id);
        List<Category> currentSubCategory = categoryMapper.selectWxAllByPid(currentCategory.getId());
        WxCataLogVo wxCataLogVo = new WxCataLogVo();
        wxCataLogVo.setCurrentCategory(currentCategory);
        wxCataLogVo.setCurrentSubCategory(currentSubCategory);
        return wxCataLogVo;
    }
}
